module teapo.koBindings { export class Scroll implements KnockoutBindingHandler { private _log: string[] = [];
valueAccessor: () => any,
allBindingsAccessor: () => any,
bindingContext: KnockoutBindingContext): void { var value = valueAccessor();
var headTag = element.outerHTML.slice(0, element.outerHTML.indexOf('>')+1); this._log.push('init(' + headTag + ') ' + typeof value +' ' + JSON.stringify(value)); console.log('init(' + headTag + ') ' + typeof value + ' ', value); element.textContent = this._log.join(' \n '); valueAccessor: () => any,
allBindingsAccessor: () => any,
bindingContext: KnockoutBindingContext): void { var value = valueAccessor();
var headTag = element.outerHTML.slice(0, element.outerHTML.indexOf('>') + 1); this._log.push('update(' + headTag + ') ' + typeof value + ' ' + JSON.stringify(value)); this._log.push('update(' + headTag + ') ' + typeof value + ' ', value); element.textContent = this._log.join(' \n '); var scroll = new Scroll();
ko.bindingHandlers['scroll'] = { init: (el, val, vi, bi) => (<any>scroll).init(el, val, vi, bi), update: (el, val, al, vi, bi) => (<any>scroll).update(el, val, al, vi, bi) };